package account_dao

import (
	"context"
	"gin-extend-demo/models/account_model"
	"log"

	"gitee.com/fkil555/gin-extend/client/gpgsql"
)

func Select(ctx context.Context) (rows []*account_model.Account, err error) {
	var id int64 = 1
	db, _ := gpgsql.GEDB.Instance("default")
	sql := "select * from employees where id=$1"
	vals := []interface{}{id}
	if err = db.Query(ctx, &rows, sql, vals...); err != nil {
		log.Println("err: ", err)
		return
	}
	return
}

func Update(ctx context.Context) (isSucc bool, err error) {
	var id int64 = 1
	db, _ := gpgsql.GEDB.Instance("default")
	sql := "update employees set name=$3,age = $1 where id = $2"
	vals := []interface{}{44, id, "lllkkkfff"}
	if _, err = db.Exec(ctx, sql, vals...); err != nil {
		log.Println("err: ", err)
		return
	}
	isSucc = true
	return
}
